/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-12-18
 * Time: 19:13
 */
public class TestDemo {
    class Solution {
        public ListNode reverseList(ListNode head) {
            if(head==null){
                return null;
            }
            if(head.next==null){
                return head;
            }
            ListNode cur=head.next;
            head.next=null;

            while(cur!=null){
                ListNode curNext=cur.next;
                cur.next=head;
                head=cur;
                cur=curNext;
            }
            return head;

        }
    }
}
